advertiserApp.controller("advertiserCtrl",function($scope,$http){
	 //console.log("data");
	 $http.post("/web-adv/finishedAd").success(function(data){
		 var sweetCookit = new sweetCookie();
		 $scope.tableData = data.beans;
		 var avdId = sweetCookit.getCookie("advId");
	/*	if(avdId){
			$scope.tableData = data.beans;		
		}else{
			window.location.href="/web-adv/advWeb/views/login/login.html";
		}*/
	 });
	 //时间格式转换
	 $scope.translate = function(t){
		 //t = t.replace(/-/g,'/');
		 //t = t.split(".")[0];		 
		 var date = new Date(t);		 
		 return date.getTime();
	 };
	 $scope.deleteAd = function(id){
		 var msg = "您确定要删除此条广告吗？";
			if (confirm(msg)){			
				$.ajax({                            
					url : '/web-adv/deleteAd',
			        data:{adId:id},
					type : 'post',
					success : function(data) {			
						if(data.status =='1'){
							$http.post("/web-adv/finishedAd").success(function(data){
								$scope.tableData = data.beans;									
							});
						}else{
							console.log("删除失败！");
						}
					},
			        error: function(){}        
				});
			};		 
	 };
	 $scope.details = function(value){
		 if(value=="video") return true;
		 return false;		 
	 }
	 
	 $scope.checkStatus = function(value){
		 if(value=="1") return false;
		 return true;		 
	 }
	 
	
});




